<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@page language="java" import= "java.util.*,data.*" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>User Information</title>
<style type="text/css">

    #Profile {
            position:absolute;
            width:188px;
            height:436px;
            z-index:1;
            left: 2px;
            top: 187px;
            font-size: small;
    }
    .Text{
            font-size:small;
            }
    #UserList {
            position:absolute;
            width:800px;
            height:387px;
            z-index:2;
            left: 192px;
            top: 191px;
            font-size: small;
            font-style: normal;
            line-height: normal;
    }
    #Header {
            position:absolute;
            width:99%;
            height:48px;
            z-index:3;
            top: 6px;
            left: 4px;
    }
    #HelloUser {
            position:relative;
            width:130px;
            height:22px;
            z-index:1;
            float: right;
            top: 2px;
    }
    #uslstLabel {
            position:absolute;
            width:430px;
            height:30px;
            z-index:4;
            left: 192px;
            top: 162px;
    }
    .style1 {
            font-size: medium;
            font-weight: bold;
            font-style: normal;
            line-height: normal;
    }
    #Body {
            position:absolute;
            width:751px;
            height:721px;
            z-index:1;
            left: -7px;
            top: -34px;
    }
    #rightPane {
            position:absolute;
            width:182px;
            height:656px;
            z-index:1;
            left: 570px;
            top: 32px;
    }
    .noneDisplay{
        display: none;
    }
    .font{
        font-size: small;
    }
	.small-font{
		font-size:x-small;
		padding-left:0px;
	}
#Layer1 {
	position:absolute;
	width:186px;
	height:228px;
	z-index:5;
	left: 153px;
	top: 406px;
}
</style>
<link href="styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
@import url("css/tablestyle.css");
.style7 {font-size: 40px}
.style8 {
	color: #FFFFFF;
	font-weight: bold;
	font-size: 16px;
	font-style: italic;
}
.style12 {font-size: 16; font-weight: bold; color: #000000; }
.style14 {font-size: 16; color: #000000; }
.style15 {color: #000000}
#Layer3 {
	position:absolute;
	width:546px;
	height:115px;
	z-index:4;
	left: 169px;
	top: 194px;
}
-->
</style>
</head>
<body>
<script src="javascript/jquery.min.js"></script>
   <script>
  
     $(document).ready(function(){
       $('input[name="delBut"]').click(function(){
         var $td= $(this).closest('tr').children('td');
         //$(this).closet('tr').deleteRow(index)
         var sr= $td.eq(1).text(); 
         //document.getElementById("hiddenbox").value = sr;
         //alert(sr);
         $.post("Delete", {del:sr}, function(){
             window.location.href = "UserInfo.jsp";
         });
       });
       $('input[name="abc123"]').click(function(){
    	   
           var $td= $(this).closest('tr').children('td');
           //$(this).closet('tr').deleteRow(index)
           var sr= $td.eq(1).text(); 
           //document.getElementById("hiddenbox").value = sr;
           //alert(sr);
           $.post("userPrivs", {View:sr}, function(){
               window.location.href = "viewDirectList.jsp";
           });
         });
       $('input[name="modify"]').click(function(event){
           event.preventDefault();
           var $td= $(this).closest('tr').children('td');  
           var id = $td.eq(0).text(); 
           var usrname = $td.eq(1).text(); 
           var deftbs = $td.eq(2).text(); 
           var tmptbs = $td.eq(3).text();
           var accstt = $td.eq(4).text();
           var quota  = $td.eq(5).text();
           var profile = $td.eq(6).text();
           //alert(id + " " + usrname + " " + full + " " + addr);
           $.post("fw",{ID : id, Usrname: usrname, def : deftbs, temp : tmptbs,
                        accStt : accstt, quo : quota, prof : profile},
                   function(data){
                       if(data.toUpperCase().indexOf("<HTML>") == -1){
                    	   alert(data);
                       }
                       window.location.href = "updateUser.jsp";
                   });
       });
       $('a[name ="modProfile"]')
       $("#view").click(function(event){
           event.preventDefault();
           if($('#UserList').is(':visible')){
               $("#UserList").css('display','none');
               $("#view").text("View user list");
           }else{
               $("#UserList").css('display','block');
               $("#view").text("Hide user list");
           }
          
       });
       $("#viewprof").click(function(event){
           event.preventDefault();
           if($('#profile').is(':visible')){
               $("#profile").css('display','none');
               $("#viewprof").text("[View]");
           }else{
               $("#profile").css('display','table-row');
               $("#viewprof").text("[Hide]");
           }
          
       });
       $("#viewrole").click(function(event){
           event.preventDefault();
           if($('#role').is(':visible')){
               $("#role").css('display','none');
               $("#viewrole").text("[View]");
           }else{
               $("#role").css('display','table-row');
               $("#viewrole").text("[Hide]");
           }
          
       });
       $('a[name="addRole"]').click(function(event){
           event.preventDefault();
           var $td= $(this).closest('tr').children('td');
           var username = $td.eq(1).text();
           //alert(username);
           $.post("grantRole", {Usrname : username}, function(){
               window.location.href = "addRole.jsp";
           });
       });
     });
        
   </script>
<jsp:useBean id="user" class="data.UserInfo" scope="session"/>
<%
                UserInfo userInf = (UserInfo)session.getAttribute("user");
                String deftbs = userInf.getDefTbspace();
                String tmptbs = userInf.getTmpTbspace();
                String accStt = userInf.getAccStatus();
                String quota = userInf.getQuota();
                String profile = userInf.getProfile();
%>
<div id="header">
    	<div class="mainLogo">
            <div class="logo style7">Information System Security </div>
            <div class="author">
              <p class="style8">&nbsp;</p>
              <p class="style8">AUTHOR : GROUP 1</p>
            </div>
        </div>
        <div class="icons">
        	<a href=""></a>&nbsp;<a href=""></a>        </div>
        <div id="navcontainer">
            <ul id="navlist">
                <li id="active"><a href="UserInfo.jsp">HOME</a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <li><a href="Profile.jsp">PROFILE </a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <li><a href="Role.jsp">ROLE</a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <%
                	if(userInf.getUsername().toUpperCase().equals("ADMIN")){
                %>
                <li><a href="Table.jsp">TABLE</a></li>
                <li class="menuSeparator"><img src="images/menuSeparator.png" alt="" /></li>
                <%} %>
                <li><a href="Contact.html">CONTACT</a></li>
            </ul>
        </div>
 <!-- TO DO -->   
<div id="Header">
  <div id="HelloUser">
      <div align="right">
          Hello <jsp:getProperty name="user" property="username"/>!
          <br>
          <a href="index.jsp">Sign out</a>      </div>
  </div>
</div>
</div>      
<div id="Profile">

<table border="1" width ="100%">
	<tr>
		<td>ID</td>
                <td><jsp:getProperty name="user" property="ID"/></td>
	</tr>
	<tr>
		<td>User Name</td>
		<td><jsp:getProperty name="user" property="username"/></td>
	</tr>
	
        <tr>
            <td>Default Tablespace</td>
            
            <td><%=deftbs%></td>
        </tr>
        <tr>
            <td>Temporary Tablespace</td>
            <td><%=tmptbs%></td>
        </tr>
        <tr>
            <td>Account status</td>
            <td><%=accStt%></td>
        </tr>
        <tr>
            <td>Quota</td>
            
            <td><%=quota%></td>
        </tr>
        <tr>
            <td>Profile</td>
            <td><%=profile%></td>
        </tr>
    
</table>
</div>
<div id="privsList"></div>





<div id="Layer3">
  <table id = "gradient-style" width = "500px" summary="Meeting Results">
    <thead>
      <tr>
        <th scope="col"><span class="style20">GRANTEE</span></th>
        <th scope="col"><span class="style20">PRIVILEGE</span></th>
        <th scope="col"><span class="style20">STATUS</span></th>
      </tr>
    </thead>
    <%
        System.out.println("viewDirectList.jsp");
        ArrayList<directPrivsInfo> privs= (ArrayList<directPrivsInfo>)session.getAttribute("directList");
        int count1 = 0;
        if(privs != null){
        for (count1 = 0; count1 < privs.size();count1++)
	        {
	            String grantee=privs.get(count1).getGrantee();
	            String priv=privs.get(count1).getPrivilege();
	            String status = privs.get(count1).getStatus();
	            System.out.println(grantee + " " + priv);
        %>
    <tr>
      <td width = "100px"><span class="style21"><%=grantee%></span></td>
      <td width = "100px"><span class="style21"><%=priv%></span></td>
      <td width = "300px"><span class="style21"><%=status%></span></td>
    </tr>
    <%
        	}
        }
        %>
  </table>
</div>
</body>
</html>